package cn.bonoon.kernel.events;

import cn.bonoon.kernel.VisibleScope;
import cn.bonoon.kernel.security.EditableException;
import cn.bonoon.kernel.support.IOperator;

public class BaseEvent implements IOperator{
	
	protected IOperator operator = empty;
	private final Object source; // 被操作的对象
	protected VisibleScope scope;
	
	public BaseEvent(IOperator operator, Object source){
		this.operator = operator;
		this.source = source;
	}
	
	public BaseEvent(Object source){
		this.source = source;
		this.scope = VisibleScope.GLOBAL;
	}

	public VisibleScope getScope() {
		return scope;
	}
	
	public void setScope(VisibleScope scope) {
		this.scope = scope;
	}
	
	public Object getSource() {
		return source;
	}
	
	@Override
	public Long getId() {
		return operator.getId();
	}

	@Override
	public String getUsername() {
		return operator.getUsername();
	}
	
	@Override
	public String getTitle() {
		return operator.getTitle();
	}
	
	@Override
	public boolean isWarning() {
		return operator.isWarning();
	}

	@Override
	public Long getOwnerId() {
		return operator.getOwnerId();
	}

	@Override
	public long toOwnerId() {
		return operator.toOwnerId();
	}

	@Override
	public String getDisplayName() {
		return operator.getDisplayName();
	}
	
	@Override
	public Long decryptId(Long id) {
		return operator.decryptId(id);
	}
	
	@Override
	public Long encryptId(Long id) {
		return operator.encryptId(id);
	}

	@Override
	public long encryptId(long id) {
		return operator.encryptId(id);
	}

	@Override
	public long decryptId(long id) {
		return operator.decryptId(id);
	}

	@Override
	public boolean isSuper() {
		return operator.isSuper();
	}
	
	@Override
	public boolean isAdmin() {
		return operator.isAdmin();
	}
	
	@Override
	public Object get(String name) {
		return operator.get(name);
	}

	@Override
	public void checkEditable() throws EditableException {
		operator.checkEditable();
	}
}
